package com.ja.util;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView;

import com.ja.domain.User;

public class Pc_Interceptor implements HandlerInterceptor {

	@Override
	public void afterCompletion(HttpServletRequest req, HttpServletResponse resp, Object obj, Exception arg3)
			throws Exception {

	}

	@Override
	public void postHandle(HttpServletRequest req, HttpServletResponse resp, Object obj, ModelAndView arg3)
			throws Exception {

	}

	@Override
	public boolean preHandle(HttpServletRequest request, HttpServletResponse resp, Object obj) throws Exception {
		HttpSession session = request.getSession();
		User user = (User) session.getAttribute("user");
		boolean flag = true;
		if(user==null) {
			resp.sendRedirect("/pc/index.do");
			flag = false;
		}
		return flag;
	}
}
